//
// Created by ✎﹏ℳ๓独赏 ☆独醉 on 2023/4/20.
//
#include<stdio.h>
void swap(int *x, int *y) {
    int t = *x;
    *x = *y;
    *y = t;
}
void sort_quick(int q[],int l , int r)
{
    if(l >= r) return;
    int i = l - 1, j = r + 1,x = q[(l+r)/2];
    while(i < j)
    {
        do i++;while(q[i] < x); //找到的值>= x
        do j--;while(q[j] > x); //找到的值<= x
        if(i<j) swap(&q[i],&q[j]);//两个值进行交换
    }
    sort_quick(q,l,j); // l - j这段区间继续排
    sort_quick(q,j+1,r); // j + 1 - r这段区间继续排
}
int main(){
    int arr[8]={10,3,9,2,8,2,7,5},i;
    sort_quick(arr,0,7);
    for(i = 0 ;i < 8 ; i++) printf("%d ",arr[i]);
    return 0;
}